#!/bin/bash 

cat /etc/passwd  | while read line ; do 
    user=$(echo $line | awk -F: '{print $1}')
    passwd=$(echo $line | awk -F: '{print $2}')
    uid=$(echo $line | awk -F: '{print $3}')
    gid=$(echo $line | awk -F: '{print $4}')
    message=$(echo $line | awk -F: '{print $5}')
    home=$(echo $line | awk -F: '{print $6}' )
    shell=$(echo $line | awk -F: '{print $7}')



    mysql -uroot -pCyj777.. -e "insert into test.passwd(user,passwd,uid,gid,message,home,shell) values('$user','$passwd',$uid,$gid,'$message','$home','$shell');"
    echo "用户添加成功" 
done
echo $(mysql -uroot -pCyj777.. -e "select * from test.passwd;")

